#!/bin/sh


ip=`/sbin/ifconfig -a eth0|grep inet|awk '{print $2}'|tr -d "addr:"|sed -n '1p'`

sudo mkdir -p /usr/elasticsearch/config
sudo chmod 777 /usr/elasticsearch/config
sudo rm -rf /usr/elasticsearch/config/elasticsearch.yml

#生成配置表 els
if [ ! -f "/usr/elasticsearch/config/elasticsearch.yml" ];then
    echo "#vincentxiaoxu">> /usr/elasticsearch/config/elasticsearch.yml
    echo "cluster.name: els">> /usr/elasticsearch/config/elasticsearch.yml
    echo "node.name: ${hostname}">> /usr/elasticsearch/config/elasticsearch.yml
    echo "network.host: 0.0.0.0">> /usr/elasticsearch/config/elasticsearch.yml
    #echo "http.port: 9200">> /usr/elasticsearch/config/elasticsearch.yml
    echo "bootstrap.memory_lock: false">> /usr/elasticsearch/config/elasticsearch.yml
    echo "bootstrap.system_call_filter: false">> /usr/elasticsearch/config/elasticsearch.yml
    #echo "path.data: /usr/elasticsearch/data">> /usr/elasticsearch/config/elasticsearch.yml
    #echo "path.logs: /usr/elasticsearch/logs">> /usr/elasticsearch/config/elasticsearch.yml
    echo "http.cors.enabled: true">> /usr/elasticsearch/config/elasticsearch.yml
    echo "http.cors.allow-origin: '*'">> /usr/elasticsearch/config/elasticsearch.yml
fi
